public class Teacher {
    private String teacherId;   // 教师编号
    private String name;        // 教师姓名
    private String gender;      // 教师性别
    private Course taughtCourse; // 所授课程（关联 Course 类）

    // 构造方法：初始化教师基本信息
    public Teacher(String teacherId, String name, String gender) {
        this.teacherId = teacherId;
        this.name = name;
        this.gender = gender;
        this.taughtCourse = null; // 初始无授课课程
    }

    // 「开课」方法：教师关联一门课程（简化为“每名教师只讲1门课”）
    public void openCourse(Course course) {
        this.taughtCourse = course;
        course.setTeacher(this); // 同时让课程关联当前教师
    }

    // Getter 方法
    public String getTeacherId() {
        return teacherId;
    }

    public String getName() {
        return name;
    }

    public String getGender() {
        return gender;
    }

    public Course getTaughtCourse() {
        return taughtCourse;
    }

    // Setter 方法
    public void setTeacherId(String teacherId) {
        this.teacherId = teacherId;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public void setTaughtCourse(Course taughtCourse) {
        this.taughtCourse = taughtCourse;
    }

    // 重写 toString，方便打印教师信息
    @Override
    public String toString() {
        return "Teacher{编号='" + teacherId + "', 姓名='" + name + "', 性别='" + gender + "', 所授课程=" 
               + (taughtCourse != null ? taughtCourse.getCourseName() : "暂无") + "}";
    }
}